package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.RewardsPunishmentMapper;
import com.ruoyi.system.domain.RewardsPunishment;
import com.ruoyi.system.service.IRewardsPunishmentService;
import com.ruoyi.common.core.text.Convert;

/**
 * 奖惩管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-04-11
 */
@Service
public class RewardsPunishmentServiceImpl implements IRewardsPunishmentService 
{
    @Autowired
    private RewardsPunishmentMapper rewardsPunishmentMapper;

    /**
     * 查询奖惩管理
     * 
     * @param rpId 奖惩管理主键
     * @return 奖惩管理
     */
    @Override
    public RewardsPunishment selectRewardsPunishmentByRpId(Long rpId)
    {
        return rewardsPunishmentMapper.selectRewardsPunishmentByRpId(rpId);
    }

    /**
     * 查询奖惩管理列表
     * 
     * @param rewardsPunishment 奖惩管理
     * @return 奖惩管理
     */
    @Override
    @DataScope(deptAlias = "e")
    public List<RewardsPunishment> selectRewardsPunishmentList(RewardsPunishment rewardsPunishment)
    {
        return rewardsPunishmentMapper.selectRewardsPunishmentList(rewardsPunishment);
    }

    /**
     * 新增奖惩管理
     * 
     * @param rewardsPunishment 奖惩管理
     * @return 结果
     */
    @Override
    public int insertRewardsPunishment(RewardsPunishment rewardsPunishment)
    {
        rewardsPunishment.setCreateTime(DateUtils.getNowDate());
        return rewardsPunishmentMapper.insertRewardsPunishment(rewardsPunishment);
    }

    /**
     * 修改奖惩管理
     * 
     * @param rewardsPunishment 奖惩管理
     * @return 结果
     */
    @Override
    public int updateRewardsPunishment(RewardsPunishment rewardsPunishment)
    {
        rewardsPunishment.setUpdateTime(DateUtils.getNowDate());
        return rewardsPunishmentMapper.updateRewardsPunishment(rewardsPunishment);
    }

    /**
     * 批量删除奖惩管理
     * 
     * @param rpIds 需要删除的奖惩管理主键
     * @return 结果
     */
    @Override
    public int deleteRewardsPunishmentByRpIds(String rpIds)
    {
        return rewardsPunishmentMapper.deleteRewardsPunishmentByRpIds(Convert.toStrArray(rpIds));
    }

    /**
     * 删除奖惩管理信息
     * 
     * @param rpId 奖惩管理主键
     * @return 结果
     */
    @Override
    public int deleteRewardsPunishmentByRpId(Long rpId)
    {
        return rewardsPunishmentMapper.deleteRewardsPunishmentByRpId(rpId);
    }

    /**
     * 清除奖惩信息
     */
    @Override
    @Scheduled(cron = "0 5 17 L * ?")
    public void clearRpInfo() {
        rewardsPunishmentMapper.clearRpInfo();
    }

    /**
     * 记一次迟到
     * @param employeeId 员工编号
     * @return 结果
     */
    @Override
    public int latePlus(long employeeId) {
        return rewardsPunishmentMapper.latePlus(employeeId);
    }

    /**
     * 记全勤
     * @param employeeId 员工编号
     * @return 结果
     */
    @Override
    public int setAttendance(long employeeId) {
        return rewardsPunishmentMapper.setAttendance(employeeId);
    }

    /**
     * 记所有人全勤
     * @return 结果
     */
    @Override
    public int setAttendanceAll() {
        return rewardsPunishmentMapper.setAttendanceAll();
    }

    /**
     * 取消全勤
     * @param employeeId 员工编号
     * @return 结果
     */
    @Override
    public int cancelAttendance(long employeeId) {
        return rewardsPunishmentMapper.cancelAttendance(employeeId);
    }
}
